package cn.com.qtgl.apis.iam.model.beans;

import cn.com.qtgl.apis.iam.model.enums.Wildcard;
import lombok.Getter;
import org.apache.commons.lang3.ObjectUtils;

import java.util.List;

@Getter
public class PostFlag implements UserFilterApi{

    private final String postCode;

    private final Boolean isWildcard;

    public PostFlag(String postCode) {
        this.postCode = ObjectUtils.defaultIfNull(postCode,"#");
        isWildcard=List.of("*","#").contains(this.postCode);
    }

    @Override
    public String getContent() {
        return ":"+postCode;
    }

    public Wildcard getWildcard(){
        switch (postCode){
            case "*":return Wildcard.ALL;
            case "#":return Wildcard.OFFICIAL;
            default:return Wildcard.NONE;
        }
    }
}
